function tokenizer (input) {
    let current = 0;
    let tokens = []
    while(current < input.length) {
        let char = input[current]
        if (/\(|\)/.test(char)) {
            tokens.push({
                type: 'paren',
                value: char
            })
            current++;
            continue;
        }
        let nameRegExp = /[a-z]/i
        if (nameRegExp.test(char)) {
            let value = ''
            while (nameRegExp.test(char)) {
                value += char
                current++
                char = input[current]
            }
            tokens.push({
                type: 'name',
                value: value
            })
            continue;            
        }
        let numberRegExp = /[0-9]/i
        if (numberRegExp.test(char)) {
            let value = ''
            while (numberRegExp.test(char)) {
                value += char
                current++
                char = input[current]
            }
            tokens.push({
                type: 'number',
                value: value
            })
            continue;            
        }        
        let WHITESPACE = /\s/;
        if (WHITESPACE.test(char)) {
          current++;
          continue;
        }
        // 字符串
        if (char === '"') {
            let value = '';
            char = input[++current];
            while (char !== '"') {
                value += char;
                char = input[++current];
            }
            char = input[++current]
            tokens.push({
                type: 'string',
                value: value
            })
            continue;
        }
        throw new TypeError('I dont know what this character is: ' + char);
    }
    return tokens;
}
const input  = '(add 2 (subtract 4 2))';

const tokens = tokenizer(input);
console.log(tokens);

const expactedToken = [
  { type: 'paren',  value: '('        },
  { type: 'name',   value: 'add'      },
  { type: 'number', value: '2'        },
  { type: 'paren',  value: '('        },
  { type: 'name',   value: 'subtract' },
  { type: 'number', value: '4'        },
  { type: 'number', value: '2'        },
  { type: 'paren',  value: ')'        },
  { type: 'paren',  value: ')'        },
]